.class public Les/z40;
.super Ljava/lang/Object;
.source "SmbNegotiation.java"

# interfaces
.implements Les/v40;


# static fields
.field private static final i:Les/x40;


# instance fields
.field private a:Z

.field private b:Ljava/lang/String;

.field private c:Ljava/net/Socket;

.field private d:I

.field private e:I

.field private f:Ljava/io/OutputStream;

.field private g:Ljava/io/InputStream;

.field private h:[B


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .line 1
    new-instance v0, Les/x40;

    invoke-direct {v0}, Les/x40;-><init>()V

    sput-object v0, Les/z40;->i:Les/x40;

    return-void
.end method

.method public constructor <init>(Ljava/lang/String;I)V
    .locals 1

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/16 v0, 0x200

    new-array v0, v0, [B

    .line 2
    iput-object v0, p0, Les/z40;->h:[B

    .line 3
    iput-object p1, p0, Les/z40;->b:Ljava/lang/String;

    .line 4
    iput p2, p0, Les/z40;->d:I

    return-void
.end method

.method private a(Ljava/io/InputStream;[BII)I
    .locals 3
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    const/4 v0, 0x0

    :goto_0
    if-ge v0, p4, :cond_1

    add-int v1, p3, v0

    sub-int v2, p4, v0

    .line 2
    invoke-virtual {p1, p2, v1, v2}, Ljava/io/InputStream;->read([BII)I

    move-result v1

    if-gtz v1, :cond_0

    goto :goto_1

    :cond_0
    add-int/2addr v0, v1

    goto :goto_0

    :cond_1
    :goto_1
    return v0
.end method

.method private a(I)V
    .locals 3
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    if-nez p1, :cond_0

    const/16 p1, 0x1bd

    .line 3
    :cond_0
    new-instance v0, Ljava/net/Socket;

    invoke-direct {v0}, Ljava/net/Socket;-><init>()V

    iput-object v0, p0, Les/z40;->c:Ljava/net/Socket;

    .line 4
    new-instance v1, Ljava/net/InetSocketAddress;

    iget-object v2, p0, Les/z40;->b:Ljava/lang/String;

    invoke-direct {v1, v2, p1}, Ljava/net/InetSocketAddress;-><init>(Ljava/lang/String;I)V

    const/16 p1, 0x3a98

    invoke-virtual {v0, v1, p1}, Ljava/net/Socket;->connect(Ljava/net/SocketAddress;I)V

    .line 5
    iget-object v0, p0, Les/z40;->c:Ljava/net/Socket;

    invoke-virtual {v0, p1}, Ljava/net/Socket;->setSoTimeout(I)V

    .line 6
    iget-object p1, p0, Les/z40;->c:Ljava/net/Socket;

    invoke-virtual {p1}, Ljava/net/Socket;->getOutputStream()Ljava/io/OutputStream;

    move-result-object p1

    iput-object p1, p0, Les/z40;->f:Ljava/io/OutputStream;

    .line 7
    iget-object p1, p0, Les/z40;->c:Ljava/net/Socket;

    invoke-virtual {p1}, Ljava/net/Socket;->getInputStream()Ljava/io/InputStream;

    move-result-object p1

    iput-object p1, p0, Les/z40;->g:Ljava/io/InputStream;

    return-void
.end method

.method static synthetic a(Les/z40;Z)Z
    .locals 0

    .line 1
    iput-boolean p1, p0, Les/z40;->a:Z

    return p1
.end method

.method private b()V
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    const-string v0, "SmbNegotiation"

    const-string v1, "shutdown!!"

    .line 1
    invoke-static {v0, v1}, Lcom/estrongs/android/util/n;->b(Ljava/lang/String;Ljava/lang/String;)V

    const/4 v0, 0x0

    .line 2
    :try_start_0
    iget-object v1, p0, Les/z40;->c:Ljava/net/Socket;

    invoke-virtual {v1}, Ljava/net/Socket;->shutdownOutput()V

    .line 3
    iget-object v1, p0, Les/z40;->f:Ljava/io/OutputStream;

    invoke-virtual {v1}, Ljava/io/OutputStream;->close()V

    .line 4
    iget-object v1, p0, Les/z40;->g:Ljava/io/InputStream;

    invoke-virtual {v1}, Ljava/io/InputStream;->close()V

    .line 5
    iget-object v1, p0, Les/z40;->c:Ljava/net/Socket;

    invoke-virtual {v1}, Ljava/net/Socket;->close()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 6
    iput-object v0, p0, Les/z40;->c:Ljava/net/Socket;

    return-void

    :catchall_0
    move-exception v1

    iput-object v0, p0, Les/z40;->c:Ljava/net/Socket;

    .line 7
    throw v1
.end method

.method private c()Z
    .locals 8
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 1
    new-instance v0, Les/y40$a;

    invoke-direct {v0}, Les/y40$a;-><init>()V

    .line 2
    new-instance v1, Les/y40;

    invoke-direct {v1, v0}, Les/y40;-><init>(Les/y40$a;)V

    .line 3
    iget v0, p0, Les/z40;->e:I

    const/4 v2, 0x1

    add-int/2addr v0, v2

    iput v0, p0, Les/z40;->e:I

    const/16 v3, 0x7d00

    if-ne v0, v3, :cond_0

    iput v2, p0, Les/z40;->e:I

    .line 4
    :cond_0
    sget-object v0, Les/z40;->i:Les/x40;

    iget v3, p0, Les/z40;->e:I

    iput v3, v0, Les/w40;->i:I

    .line 5
    iget-object v3, p0, Les/z40;->h:[B

    const/4 v4, 0x4

    invoke-virtual {v0, v3, v4}, Les/w40;->encode([BI)I

    move-result v0

    const v3, 0xffff

    and-int v5, v0, v3

    .line 6
    iget-object v6, p0, Les/z40;->h:[B

    const/4 v7, 0x0

    invoke-static {v5, v6, v7}, Ljcifs/util/Encdec;->enc_uint32be(I[BI)I

    .line 7
    iget-object v5, p0, Les/z40;->f:Ljava/io/OutputStream;

    iget-object v6, p0, Les/z40;->h:[B

    add-int/2addr v0, v4

    invoke-virtual {v5, v6, v7, v0}, Ljava/io/OutputStream;->write([BII)V

    .line 8
    iget-object v0, p0, Les/z40;->f:Ljava/io/OutputStream;

    invoke-virtual {v0}, Ljava/io/OutputStream;->flush()V

    .line 9
    invoke-direct {p0}, Les/z40;->e()Z

    move-result v0

    if-eqz v0, :cond_4

    .line 10
    iget-object v0, p0, Les/z40;->h:[B

    const/4 v5, 0x2

    invoke-static {v0, v5}, Ljcifs/util/Encdec;->dec_uint16be([BI)S

    move-result v0

    and-int/2addr v0, v3

    const/16 v3, 0x21

    if-lt v0, v3, :cond_3

    add-int/lit8 v3, v0, 0x4

    .line 11
    iget-object v5, p0, Les/z40;->h:[B

    array-length v6, v5

    if-gt v3, v6, :cond_3

    .line 12
    iget-object v3, p0, Les/z40;->g:Ljava/io/InputStream;

    const/16 v6, 0x24

    add-int/lit8 v0, v0, -0x20

    invoke-direct {p0, v3, v5, v6, v0}, Les/z40;->a(Ljava/io/InputStream;[BII)I

    .line 13
    iget-object v0, p0, Les/z40;->h:[B

    invoke-virtual {v1, v0, v4}, Les/w40;->decode([BI)I

    .line 14
    invoke-virtual {v1}, Les/w40;->a()I

    move-result v0

    if-eqz v0, :cond_1

    const-string v0, "SmbNegotiation"

    const-string v1, "negotiate smb1 failure"

    .line 15
    invoke-static {v0, v1}, Lcom/estrongs/android/util/n;->b(Ljava/lang/String;Ljava/lang/String;)V

    return v7

    .line 16
    :cond_1
    iget v0, v1, Les/y40;->o:I

    const/16 v1, 0xa

    if-le v0, v1, :cond_2

    return v7

    :cond_2
    return v2

    .line 17
    :cond_3
    new-instance v1, Ljava/io/IOException;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "Invalid payload size: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-direct {v1, v0}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 18
    :cond_4
    new-instance v0, Ljava/io/IOException;

    const-string v1, "transport closed in negotiate"

    invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw v0
.end method

.method private d()Z
    .locals 4
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 1
    new-instance v0, Les/md0;

    invoke-direct {v0}, Les/md0;-><init>()V

    .line 2
    new-instance v1, Lcom/hierynomus/smbj/smb2/messages/h;

    invoke-interface {v0}, Les/kd0;->a()Ljava/util/EnumSet;

    move-result-object v2

    invoke-interface {v0}, Les/kd0;->b()Ljava/util/UUID;

    move-result-object v0

    invoke-direct {v1, v2, v0}, Lcom/hierynomus/smbj/smb2/messages/h;-><init>(Ljava/util/EnumSet;Ljava/util/UUID;)V

    .line 3
    new-instance v0, Lcom/hierynomus/smbj/common/b;

    invoke-direct {v0}, Lcom/hierynomus/smbj/common/b;-><init>()V

    .line 4
    invoke-virtual {v1, v0}, Lcom/hierynomus/smbj/smb2/d;->c(Lcom/hierynomus/smbj/common/b;)V

    .line 5
    new-instance v1, Les/yd0;

    invoke-direct {v1, v0}, Les/yd0;-><init>(Lcom/hierynomus/smbj/common/b;)V

    .line 6
    iget-object v0, p0, Les/z40;->f:Ljava/io/OutputStream;

    invoke-virtual {v1}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->a()[B

    move-result-object v2

    invoke-virtual {v1}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->l()I

    move-result v3

    invoke-virtual {v1}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->c()I

    move-result v1

    invoke-virtual {v0, v2, v3, v1}, Ljava/io/OutputStream;->write([BII)V

    .line 7
    iget-object v0, p0, Les/z40;->f:Ljava/io/OutputStream;

    invoke-virtual {v0}, Ljava/io/OutputStream;->flush()V

    const/4 v0, 0x0

    .line 8
    iput-boolean v0, p0, Les/z40;->a:Z

    .line 9
    new-instance v0, Les/zd0;

    iget-object v1, p0, Les/z40;->g:Ljava/io/InputStream;

    new-instance v2, Les/z40$a;

    invoke-direct {v2, p0}, Les/z40$a;-><init>(Les/z40;)V

    invoke-direct {v0, v1, v2}, Les/zd0;-><init>(Ljava/io/InputStream;Lcom/hierynomus/smbj/transport/b;)V

    .line 10
    invoke-virtual {v0}, Lcom/hierynomus/smbj/transport/c;->run()V

    .line 11
    iget-boolean v0, p0, Les/z40;->a:Z

    return v0
.end method

.method private e()Z
    .locals 7
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 1
    :cond_0
    iget-object v0, p0, Les/z40;->g:Ljava/io/InputStream;

    iget-object v1, p0, Les/z40;->h:[B

    const/4 v2, 0x4

    const/4 v3, 0x0

    invoke-direct {p0, v0, v1, v3, v2}, Les/z40;->a(Ljava/io/InputStream;[BII)I

    move-result v0

    if-ge v0, v2, :cond_1

    return v3

    .line 2
    :cond_1
    iget-object v0, p0, Les/z40;->h:[B

    aget-byte v1, v0, v3

    const/16 v4, -0x7b

    if-eq v1, v4, :cond_0

    .line 3
    iget-object v1, p0, Les/z40;->g:Ljava/io/InputStream;

    const/16 v4, 0x20

    invoke-direct {p0, v1, v0, v2, v4}, Les/z40;->a(Ljava/io/InputStream;[BII)I

    move-result v0

    if-ge v0, v4, :cond_2

    return v3

    .line 4
    :cond_2
    :goto_0
    iget-object v0, p0, Les/z40;->h:[B

    aget-byte v1, v0, v3

    const/4 v4, -0x1

    if-nez v1, :cond_3

    const/4 v1, 0x1

    aget-byte v5, v0, v1

    if-nez v5, :cond_3

    aget-byte v5, v0, v2

    if-ne v5, v4, :cond_3

    const/4 v5, 0x5

    aget-byte v5, v0, v5

    const/16 v6, 0x53

    if-ne v5, v6, :cond_3

    const/4 v5, 0x6

    aget-byte v5, v0, v5

    const/16 v6, 0x4d

    if-ne v5, v6, :cond_3

    const/4 v5, 0x7

    aget-byte v0, v0, v5

    const/16 v5, 0x42

    if-ne v0, v5, :cond_3

    return v1

    :cond_3
    const/4 v0, 0x0

    :goto_1
    const/16 v1, 0x23

    if-ge v0, v1, :cond_4

    .line 5
    iget-object v1, p0, Les/z40;->h:[B

    add-int/lit8 v5, v0, 0x1

    aget-byte v6, v1, v5

    aput-byte v6, v1, v0

    move v0, v5

    goto :goto_1

    .line 6
    :cond_4
    iget-object v0, p0, Les/z40;->g:Ljava/io/InputStream;

    invoke-virtual {v0}, Ljava/io/InputStream;->read()I

    move-result v0

    if-ne v0, v4, :cond_5

    return v3

    .line 7
    :cond_5
    iget-object v4, p0, Les/z40;->h:[B

    int-to-byte v0, v0

    aput-byte v0, v4, v1

    goto :goto_0
.end method


# virtual methods
.method public declared-synchronized a()I
    .locals 1

    monitor-enter p0

    .line 8
    :try_start_0
    iget v0, p0, Les/z40;->d:I

    invoke-direct {p0, v0}, Les/z40;->a(I)V

    .line 9
    invoke-direct {p0}, Les/z40;->c()Z

    move-result v0

    .line 10
    invoke-direct {p0}, Les/z40;->b()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-eqz v0, :cond_0

    const/4 v0, 0x1

    .line 11
    monitor-exit p0

    return v0

    :catchall_0
    move-exception v0

    goto :goto_0

    :catch_0
    move-exception v0

    .line 12
    :try_start_1
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 13
    :cond_0
    :try_start_2
    iget v0, p0, Les/z40;->d:I

    invoke-direct {p0, v0}, Les/z40;->a(I)V

    .line 14
    invoke-direct {p0}, Les/z40;->d()Z

    move-result v0

    .line 15
    invoke-direct {p0}, Les/z40;->b()V
    :try_end_2
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_1
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    if-eqz v0, :cond_1

    const/4 v0, 0x2

    .line 16
    monitor-exit p0

    return v0

    :catch_1
    move-exception v0

    .line 17
    :try_start_3
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    :cond_1
    const/4 v0, 0x0

    .line 18
    monitor-exit p0

    return v0

    :goto_0
    monitor-exit p0

    throw v0
.end method
